package ua.com.toltec.flymodemanager;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class RepeatingAlarmService extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
//    	
//        Toast.makeText(context, pr.calendar2string(pr.milliseconds2calendar(pr.getNextInterval())), Toast.LENGTH_LONG).show();
//        Log.v(this.getClass().getName(), "Timed alarm onReceive() started at time: " + new java.sql.Timestamp(System.currentTimeMillis()).toString());
    	context.stopService(new Intent(context, ServiceAirplaneMode.class));
    	PreferenceUnit pr = new PreferenceUnit(context);
    	String task = pr.getCurentTask();
    	if (task.equals(Constants.FLYMODEOFF)) {
			RadioServiceUnit.setAirplaneMode(context, false);
		} else if (task.equals(Constants.FLYMODEON)) {
			RadioServiceUnit.setAirplaneMode(context, true);
		}
    	
    	context.startService(new Intent(context, ServiceAirplaneMode.class));
    }
}